package com.xcm.controller;

import com.xcm.exception.ControllerException;
import com.xcm.service.PollConfigService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 轮询配置Controller
 */
@Controller
@RequestMapping(value = "/pollConfig")
public class PollConfigController {
	private static Logger logger = LoggerFactory.getLogger(PollConfigController.class);
	@Autowired
	private PollConfigService pollConfigService;

	/**
	 * 获取所有轮询配置信息
	 */
	@ResponseBody
	@RequestMapping(value = "/getConfig")
	public Object getConfig() {
		try {
			return pollConfigService.getAllPollConfig();
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("PollConfigController getConfig 获取所有轮询配置信息失败：" + e.getMessage());
			return new ControllerException("获取所有轮询配置信息失败");
		}
	}
}
